package com.example.forum_system.dao;

import com.example.forum_system.model.ArticleReply;
import com.example.forum_system.model.VO.ArticleReplyVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ArticleReplyMapper {
    //1.新增文章评论
    @Insert("insert into t_reply(articleId, postUserId, content, likeCount, state, deleteState, createTime, updateTime) values (#{articleId}, #{postUserId}, #{content}, #{likeCount}, #{state}, #{deleteState}, #{createTime}, #{updateTime})")
    int insertReply(ArticleReply articleReply);

    //2.获取评论列表,根据文章id
    @Select("select * from t_reply where articleId=#{articlerId} and deleteState=0 order by updateTime desc")
    List<ArticleReplyVO> selectRepliesByArticle(long articleId);

    //3.获得评论总数,根据文章id
    @Select("select COUNT(id) from t_reply where articleId=#{articleId}")
    int selectCountByArticle(long articleId);
//
//    int insert(ArticleReply row);
//
//    int insertSelective(ArticleReply row);
//
//    ArticleReply selectByPrimaryKey(Long id);
//
//    int updateByPrimaryKeySelective(ArticleReply row);
//
//    int updateByPrimaryKey(ArticleReply row);
}